home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 361_01 / pxo.c < prev    next >
C/C++ Source or Header  |  1991-09-18  |  1KB  |  57 lines

  1.  
  2. /* PXO.C  --> A Pipe Extension OutFlow Tool w/ Named Pipes.
  3.  *
  4.  * Jack Ekwall 2 May 89
  5.  *
  6.  * Copyrighted to the Public Domain.  Unlimited Distribution Authorized.
  7.  *
  8.  * User Assumes All Risks/Liabilities.
  9.  *
  10.  * Last Update:  29 September 89/EK
  11.  */
  12.  
  13. #include <stdio.h>
  14. #include <stdek.h>
  15. #include <ctype.h>
  16. #include <string.h>
  17.  
  18. /* Delare Globals */
  19. char Pipe[16] = "\\STD OUT";
  20.  
  21. /* Declare Prototypes */
  22. void Usage(void);
  23.  
  24. main (int argc, char *argv[])
  25. {
  26.     int c, i;
  27.     FILE *fp = stdout;
  28.  
  29.  /* Check for a Pipe Name */
  30.     if (argc > 2) Usage();
  31.     if (argc IS 2) {
  32.        if (*argv[1]++ != '$') Usage();
  33.        if (strlen(argv[1]) > 4 || *argv[1] IS NULL) Usage();
  34.        strcpy(Pipe + 5,argv[1]);
  35.     }
  36.  
  37.  /* Check for Pipes */
  38.     if (!INFLOW_EXISTS) Usage();
  39.     if (OUTFLOW_EXISTS)
  40.        if ((fp = fopen(Pipe,"a")) IS NULL) { perror(Pipe); exit(1); }
  41.  
  42.  /* Stream Text to Specified Target */
  43.     while ((c = getchar()) != EOF) putc(c, fp);
  44.     exit(0);
  45. }
  46.  
  47. void Usage()
  48. {
  49.     fprintf(stderr,"\n\nUsage:\n");
  50.     fprintf(stderr,"      PXO [$Pipe] ---> BATch File PX/CRT Pipe Cap.\n\n");
  51.     fprintf(stderr,
  52. "      IF Called By PX & Outflow is Piped, PXO Squirts Text into \"\\STD OUT\" or\n");
  53.     fprintf(stderr,
  54. "      into Specified Named Pipe.  (Name = 1-4 Alpha-numeric Characters.)\n\n");
  55.     exit(1);
  56. }
  57.